< previous page page_616 next page >

Page 616
An Example of a Toolbar
To create a toolbar, you need to have an ImageList control from which you can create each button. After adding a ListImage control to the form, you need to assign all the images that you want to use on your toolbar. Make sure you assign all of them prior to adding buttons to the toolbar, because once youve assigned the ImageList property on the toolbar, you cant change the ImageList control. This means you have to redo your entire toolbar if you want to add just one more icon.
Look at the sample project for this chapter. Youll find an ImageList control and a toolbar control already created. Click the ImageList control, select Custom from the Properties window, and view the images that have been added to this control. Next, click the toolbar control and select the Custom property to view all the buttons on the Buttons tab of the property page.
Examples Filename: Toolbar.frm
In Figure 30.3, you can see each of the different types of button styles. Run this example and click each of the different buttons to see what it does. To make a button respond and perform an action, you need to write code in the ButtonClick event:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub tbrMain_ButtonClick(ByVal Button As Button)
   Select Case Button.Key
      Case "NewRecord"
         MsgBox "Add a new record here"
      Case "SaveRecord"
         MsgBox "Save changes here"
      Case "DeleteRecord"
         MsgBox "Delete a record here"
      Case "UndoRecord"
         MsgBox "Undo changes to a particular record"
      Case "Copy"
         MsgBox "Copy code goes here"
      Case "Cut"
         MsgBox "Cut code goes here"
      Case "Paste"
         MsgBox "Paste code goes here"
      Case "Exit"
         Unload Me
   End Select
End Sub

 
< previous page page_616 next page >

If you like this book, buy it!